﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Acms.Bll;

public partial class Posts_Default2 : BasePostPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        dsPostsPublishing.SelectData += new EventHandler<Acms.DataControls.SelectEventArgs<Post>>(dsPostsPublishing_SelectData);
        if (!IsPostBack)
        {
        }
    }

    void dsPostsPublishing_SelectData(object sender, Acms.DataControls.SelectEventArgs<Post> e)
    {
        e.SetData(Acms.Bll.Post.GetAllWhereRequiresPublishing(AcmsContext.SiteId));
    }

    protected override string PageTitle
    {
        get { return ""; }
    }


    public override Role.Roles[] AllowedRoles
    {
        get { return new Acms.Bll.Role.Roles[] { Role.Roles.Developer, Role.Roles.ContentEditor, Role.Roles.ContentViewer, Role.Roles.ContentPublisher }; }
    }

    public Role.Roles[] PublishRoles
    {
        get { return new Acms.Bll.Role.Roles[] { Role.Roles.Developer, Role.Roles.ContentPublisher }; }
    }

    protected void lnkPreview_DataBinding(object sender, EventArgs e)
    {
        var lnkPreview = sender as HyperLink;
        if (lnkPreview != null)
        {
            Telerik.Web.UI.GridDataItem dataItem = lnkPreview.NamingContainer as Telerik.Web.UI.GridDataItem;
            if (dataItem != null)
            {
                var post = dataItem.DataItem as Acms.Bll.Post;
                lnkPreview.NavigateUrl = string.Concat("http://", AcmsContext.SiteRoot, "/", post.Url.Substring(2));
            } 
        }
    }

}
